Contracts
Get a list of contracts in ascending order
Get a list of contracts, sorted ascending by the time they were first seen by the explorer. If the not_decompiled
(4
) or not_verified(4)
filters are applied, the results will not be sorted for performance reasons
?module=contract
&action=listcontracts
Parameters:
Name | Description |
---|---|
Module* | A string with the name of the module to be invoked. |
Must be set to: contract | | Action* | A string with the name of the action to be invoked.
Must be set to: listcontracts | | page | A nonnegative integer that represents the page number to be used for pagination. 'offset' must be provided in conjunction. | | offset | A nonnegative integer that represents the maximum number of records to return when paginating. 'page' must be provided in conjunction. | | filter | verified|decompiled|unverified|not_decompiled|empty, or 1|2|3|4|5 respectively. This requests only contracts with that status. | | not_decompiled_with_version | Ensures that none of the returned contracts were decompiled with the provided version. Ignored unless filtering for decompiled contracts. |
Responses
Code 200 (successful)
{
"message": "OK",
"result": [
{
"ABI": "[{\n\"type\":\"event\",\n\"inputs\": [{\"name\":\"a\",\"type\":\"uint256\",\"indexed\":true},{\"name\":\"b\",\"type\":\"bytes32\",\"indexed\":false}],\n\"name\":\"Event\"\n}, {\n\"type\":\"event\",\n\"inputs\": [{\"name\":\"a\",\"type\":\"uint256\",\"indexed\":true},{\"name\":\"b\",\"type\":\"bytes32\",\"indexed\":false}],\n\"name\":\"Event2\"\n}, {\n\"type\":\"function\",\n\"inputs\": [{\"name\":\"a\",\"type\":\"uint256\"}],\n\"name\":\"foo\",\n\"outputs\": []\n}]\n",
"CompilerVersion": "v0.2.1-2016-01-30-91a6b35",
"ContractName": "Test",
"OptimizationUsed": "1",
"SourceCode": "pragma solidity >0.4.24;\n\ncontract Test {\nconstructor() public { b = hex\"12345678901234567890123456789012\"; }\nevent Event(uint indexed a, bytes32 b);\nevent Event2(uint indexed a, bytes32 b);\nfunction foo(uint a) public { emit Event(a, b); }\nbytes32 b;\n}\n"
}
],
"status": "1"
}
Get ABI for verified contract
Returns the Contract Application Binary Interface ( ABI ) of a verified smart contract.
?module=contract
&action=getabi
&address={addressHash}
Parameters
Name | Description |
---|---|
Module* | A string with the name of the module to be invoked. |
Must be set to: contract | | Action* | A string with the name of the action to be invoked.
Must be set to: getabi | | Address* | A 160-bit code used for identifying contracts. |
Responses
Code 200 (successful)
{
"message": "OK",
"result": "[{\"constant\":false,\"inputs\":[{\"name\":\"voucher_token\",\"type\":\"bytes32\"}],\"name\":\"burn\",\"outputs\":[{\"name\":\"success\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[{\"name\":\"voucher_token\",\"type\":\"bytes32\"}],\"name\":\"is_expired\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"},{\"constant\":false,\"inputs\":[{\"name\":\"voucher_token\",\"type\":\"bytes32\"}],\"name\":\"is_burnt\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"name\":\"voucher_token\",\"type\":\"bytes32\"},{\"name\":\"_lifetime\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"}]",
"status": "1"
}
Code 200 (error)
{
"message": "Contract source code not verified",
"result": null,
"status": "0"
}
Get contract source code for verified contract.
Returns the Solidity source code of a verified smart contract.
?module=contract
&action=getsourcecode
&address={addressHash}
Name | Description |
---|---|
Module* | A string with the name of the module to be invoked. |
Must be set to: contract | | Action* | A string with the name of the action to be invoked.
Must be set to: getsourcecode | | Address* | A 160-bit code used for identifying contracts. |
Response
Code 200 (successful)
{
"message": "OK",
"result": {
"ABI": "[{\n\"type\":\"event\",\n\"inputs\": [{\"name\":\"a\",\"type\":\"uint256\",\"indexed\":true},{\"name\":\"b\",\"type\":\"bytes32\",\"indexed\":false}],\n\"name\":\"Event\"\n}, {\n\"type\":\"event\",\n\"inputs\": [{\"name\":\"a\",\"type\":\"uint256\",\"indexed\":true},{\"name\":\"b\",\"type\":\"bytes32\",\"indexed\":false}],\n\"name\":\"Event2\"\n}, {\n\"type\":\"function\",\n\"inputs\": [{\"name\":\"a\",\"type\":\"uint256\"}],\n\"name\":\"foo\",\n\"outputs\": []\n}]\n",
"CompilerVersion": "v0.2.1-2016-01-30-91a6b35",
"ContractName": "Test",
"FileName": "{sourcify path or empty}",
"OptimizationUsed": "1",
"SourceCode": "pragma solidity >0.4.24;\n\ncontract Test {\nconstructor() public { b = hex\"12345678901234567890123456789012\"; }\nevent Event(uint indexed a, bytes32 b);\nevent Event2(uint indexed a, bytes32 b);\nfunction foo(uint a) public { emit Event(a, b); }\nbytes32 b;\n}\n"
},
"status": "1"
}
Code 200 (error)
{
"message": "Invalid address hash",
"result": null,
"status": "0"
}
Verify a contract with its source code and contract creation information.
Request
curl -d '{"addressHash":"0xc63BB6555C90846afACaC08A0F0Aa5caFCB382a1","compilerVersion":"v0.5.4+commit.9549d8ff", "contractSourceCode":"pragma solidity ^0.5.4; contract Test { }","name":"Test","optimization":false}' -H "Content-Type: application/json" -X POST "https://blockscout.com/poa/sokol/api?module=contract&action=verify"
?module=contract
&action=verify
&addressHash={addressHash}
&name={name}
&compilerVersion={compilerVersion}
&optimization={false}
&contractSourceCode={contractSourceCode}
Parameters
ADD IMAGES HERE
Responses
Code 200 (successful)
{
"message": "OK",
"result": {
"ABI": "[{\n\"type\":\"event\",\n\"inputs\": [{\"name\":\"a\",\"type\":\"uint256\",\"indexed\":true},{\"name\":\"b\",\"type\":\"bytes32\",\"indexed\":false}],\n\"name\":\"Event\"\n}, {\n\"type\":\"event\",\n\"inputs\": [{\"name\":\"a\",\"type\":\"uint256\",\"indexed\":true},{\"name\":\"b\",\"type\":\"bytes32\",\"indexed\":false}],\n\"name\":\"Event2\"\n}, {\n\"type\":\"function\",\n\"inputs\": [{\"name\":\"a\",\"type\":\"uint256\"}],\n\"name\":\"foo\",\n\"outputs\": []\n}]\n",
"CompilerVersion": "v0.2.1-2016-01-30-91a6b35",
"ContractName": "Test",
"OptimizationUsed": "1",
"SourceCode": "pragma solidity >0.4.24;\n\ncontract Test {\nconstructor() public { b = hex\"12345678901234567890123456789012\"; }\nevent Event(uint indexed a, bytes32 b);\nevent Event2(uint indexed a, bytes32 b);\nfunction foo(uint a) public { emit Event(a, b); }\nbytes32 b;\n}\n"
},
"status": "1"
}
Code 200 (error)
{
"message": "There was an error verifying the contract.",
"result": null,
"status": "0"
}
Verify a contract through Sourcify.
a) if smart-contract already verified on Sourcify, it will automatically fetch the data from the repo b) otherwise you have to upload source files and JSON metadata file(s).
?module=contract
&action=verify_via_sourcify
&addressHash={addressHash}
Verify a Vyper contract with its source code and contract creation information.
curl --location --request POST 'http://localhost:4000/api?module=contract&action=verify_vyper_contract' --form 'contractSourceCode="SOURCE_CODE"' --form 'name="Vyper_contract"' --form 'addressHash="0xE60B1B8bD493569a3E945be50A6c89d29a560Fa1"' --form 'compilerVersion="v0.2.12"'
?module=contract
&action=verify_vyper_contract
&addressHash={addressHash}
&name={name}
&compilerVersion={compilerVersion}
&contractSourceCode={contractSourceCode}
Verify a contract with Standard input JSON file. Its interface the same as WYZthScan's API endpoint
?module=contract
&action=verifysourcecode
&codeformat={solidity-standard-json-input}
&contractaddress={contractaddress}
&contractname={contractname}
&compilerversion={compilerversion}
&sourceCode={sourceCode}
Return status of the verification attempt
?module=contract
&action=checkverifystatus
&guid={identifierString}
Verify Source code (Not sure)
- Requires a valid Wyzth API Key, it will be rejected otherwise
- Only supports HTTP POST due to max transfer size limitations for HTTP GET
- Supports up to 10 different library pairs.
- Contracts that use "imports" will need to have the code concatenated into one file as we do not support "imports" in separate files.
- List of supported solc versions, only solc version v0.4.11 and above is supported e.g. v0.4.25+commit.59dbf8f1
- Upon successful submission you will receive a GUID (50 characters) as a receipt.
- You may use this GUID to track the status of your submission.
- Verified Source Codes will be displayed at the Verified Contracts page.